import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";

import { routes } from "./router.config"



const router = createRouter({
    history: createWebHistory(),
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) return savedPosition
        else return { top: 0 }
    },
    routes
})

// 路由开始进入
router.beforeEach((to: any, from: any, next) => {
    console.log('进入==>>' + to.meta.title + '<<==进入')
    console.log('从这里来的==>>' + from.meta.title + '<<==从这里来的')
    next()
    return false
})

router.afterEach((to, from, next) => {
    // 保存url
    console.log('我进来了')
})



export default router